<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-row>
          <el-form :model="form" inline>
            <el-form-item label="日期范围">
              <el-date-picker
                v-model="form.start_time"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择开始时间"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="">
              <el-date-picker
                v-model="form.end_time"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择结束时间"
              ></el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="success" @click="deBounceWrap(handleClick)"
                >导出</el-button
              >
            </el-form-item>
          </el-form>
        </el-row>
      </div>
    </el-card>
  </div>
</template>
<script>
import { UserExport } from "@/api/order/rechargeUsers";

export default {
  data() {
    return {
      form: {
        start_time: undefined,
        end_time: undefined
      }
    };
  },
  created() {},
  methods: {
    handleClick() {
      let data = {};
      if (this.form.start_time) {
        data.start_time = this.form.start_time;
      }
      if (this.form.end_time) {
        data.end_time = this.form.end_time;
      }
      if (this.form.end_time < this.form.start_time) {
        this.$message.warning("请选择正确的时间");
        return;
      }
      UserExport(data).then(res => {
        location.href = res.data.download_url;
      });
    }
  }
};
</script>
<style scoped></style>
